package com.caigou.modules.query.adpter

import android.graphics.Color
import android.widget.TextView
import com.caigou.modules.query.R
import com.caigou.modules.query.bean.ColdHotDetailItemBean
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

/**
 * @author #Suyghur.
 * Created on 2021/12/19
 */
class ColdHotDetailItemAdapter(private val number: String, dataset: MutableList<ColdHotDetailItemBean>) :
    BaseQuickAdapter<ColdHotDetailItemBean, BaseViewHolder>(R.layout.item_cold_hot_detail_list, dataset) {
    override fun convert(holder: BaseViewHolder, item: ColdHotDetailItemBean) {
        holder.setText(R.id.item_cold_hot_detail_tv_period, "${item.year}-${item.period}")
        with(holder.getView<TextView>(R.id.item_cold_hot_detail_tv_1)) {
            val num = item.prizeList[0].number
            text = num
            if (num == number) {
                setBackgroundResource(R.drawable.query_circle_btn_red)
                setTextColor(Color.parseColor("#FFFFFF"))
            } else {
                setBackgroundResource(0)
                setTextColor(Color.parseColor("#505050"))
            }
        }
        with(holder.getView<TextView>(R.id.item_cold_hot_detail_tv_2)) {
            val num = item.prizeList[1].number
            text = num
            if (num == number) {
                setBackgroundResource(R.drawable.query_circle_btn_red)
                setTextColor(Color.parseColor("#FFFFFF"))
            } else {
                setBackgroundResource(0)
                setTextColor(Color.parseColor("#505050"))
            }
        }
        with(holder.getView<TextView>(R.id.item_cold_hot_detail_tv_3)) {
            val num = item.prizeList[2].number
            text = num
            if (num == number) {
                setBackgroundResource(R.drawable.query_circle_btn_red)
                setTextColor(Color.parseColor("#FFFFFF"))
            } else {
                setBackgroundResource(0)
                setTextColor(Color.parseColor("#505050"))
            }
        }
        with(holder.getView<TextView>(R.id.item_cold_hot_detail_tv_4)) {
            val num = item.prizeList[3].number
            text = num
            if (num == number) {
                setBackgroundResource(R.drawable.query_circle_btn_red)
                setTextColor(Color.parseColor("#FFFFFF"))
            } else {
                setBackgroundResource(0)
                setTextColor(Color.parseColor("#505050"))
            }
        }
        with(holder.getView<TextView>(R.id.item_cold_hot_detail_tv_5)) {
            val num = item.prizeList[4].number
            text = num
            if (num == number) {
                setBackgroundResource(R.drawable.query_circle_btn_red)
                setTextColor(Color.parseColor("#FFFFFF"))
            } else {
                setBackgroundResource(0)
                setTextColor(Color.parseColor("#505050"))
            }
        }
        with(holder.getView<TextView>(R.id.item_cold_hot_detail_tv_6)) {
            val num = item.prizeList[5].number
            text = num
            if (num == number) {
                setBackgroundResource(R.drawable.query_circle_btn_red)
                setTextColor(Color.parseColor("#FFFFFF"))
            } else {
                setBackgroundResource(0)
                setTextColor(Color.parseColor("#505050"))
            }
        }
        with(holder.getView<TextView>(R.id.item_cold_hot_detail_tv_te_ma)) {
            val num = item.prizeList[6].number
            text = num
            if (num == number) {
                setBackgroundResource(R.drawable.query_circle_btn_red)
                setTextColor(Color.parseColor("#FFFFFF"))
            } else {
                setBackgroundResource(0)
                setTextColor(Color.parseColor("#505050"))
            }
        }
    }
}